﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MainClient
{
    public partial class frmEditOrderItem : Form
    {
        private string strOrderID;
        public frmEditOrderItem(
                        string strOrderID, string strFoodID, string strFoodName,
                        int iCount, string strCookID, string strNotes)
        {
            InitializeComponent();
            this.strOrderID = strOrderID;
            this.lbl_foodID.Text = strFoodID;
            this.lbl_foodName.Text = strFoodName;
            this.nud_count.Value = iCount;
            this.txt_cookID.Text = strCookID;
            this.txt_notes.Text = strNotes;
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            DataAccess.OrderDAO orderDAO = new DataAccess.OrderDAO();
            bool isSucc = orderDAO.updateOrderFood(
                                                       LoginUser.getCurrOper(),
                                                       this.strOrderID,
                                                       this.lbl_foodID.Text.Trim(),
                                                       Int32.Parse(this.nud_count.Value.ToString()),
                                                       this.txt_notes.Text.Trim(),
                                                       this.txt_cookID.Text.Trim());
            if (isSucc)
            {
                string strShow = "修改 编号: " + this.lbl_foodID.Text.Trim() + " 成功!";
                MessageBox.Show(strShow, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                string strShow = "网络连接失败或不存在该条目, 修改订单内容失败！";
                MessageBox.Show(strShow, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }
    }
}
